package com.free.note.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.free.compilation.domain.ZoneCompilation;
import com.free.note.domain.ZoneNote;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 笔记Mapper接口
 *
 * @author YHL
 * @date 2023-02-26
 */
public interface ZoneNoteMapper extends BaseMapper<ZoneNote> {
    //    @Select("SELECT * FROM zone_note WHERE id NOT IN ( SELECT id FROM note_random_count WHERE random_count = ( SELECT MIN( random_count ) FROM note_random_count )) AND classify IN ( 101, 109 ) ORDER BY RAND() LIMIT 1;")
    @Select("SELECT id FROM zone_note WHERE classify IN ( ${classify} ) AND external_display = 1 ORDER BY RAND() ;")
    List<Integer> randomOne(@Param("classify") String classify);

    @Select(" SELECT * from zone_compilation WHERE id in ( select compilation_id from zone_compilation_step where note_id = #{noteId} )")
    List<ZoneCompilation> selectRelevanceCompilation(Long noteId);

}
